<?php defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

/* JoomLeague League Management and Prediction Game for Joomla!
 * Copyright (C) 2007  Robert Moss
 *  
 * Homepage: http://www.joomleague.de
 * Support: htt://www.joomleague.de/forum/
 * 
 * This file is part of JoomLeague.
 *  
 * JoomLeague is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * Please note that the GPL states that any headers in files and
 * Copyright notices as well as credits in headers, source files
 * and output (screens, prints, etc.) can not be removed.
 * You can extend them with your own credits, though...
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * The "GNU General Public License" (GPL) is available at
 * http://www.gnu.org/copyleft/gpl.html.
*/ 

?>

<link rel="stylesheet" type="text/css" media="all" href="<?php echo $mosConfig_live_site;?>/includes/js/calendar/calendar-mos.css" title="green" />
<div id="overDiv" style="position:absolute; visibility:hidden; z-index:10000;"></div>
		<!-- import the calendar script -->
		<script language="javascript" type="text/javascript" src="<?php echo $mosConfig_live_site;?>/includes/js/calendar/calendar_mini.js"></script>
		<!-- import the language module -->
		<script language="javascript" type="text/javascript" src="<?php echo $mosConfig_live_site;?>/includes/js/calendar/lang/calendar-en.js"></script>
	  	<script language="javascript" type="text/javascript" src="<?php echo $mosConfig_live_site;?>/includes/js/overlib_mini.js"></script>
<script language="javascript" type="text/javascript">

  function submitbutton(pressbutton) {
  	var form = document.adminForm;
  	if (pressbutton == 'cancel') {
  		submitform( pressbutton );
  		return;
  	}
  
  	// do field validation
  	if (form.name.value == '') {
  		alert( "<?php echo _JL_ADMIN_EDIT_FORM_MATCHES_JS_CHECK;?>" );
  	} else {
      <?php getEditorContents( 'editor1', 'summary' ) ; ?>
  		submitform( pressbutton );
  	}
  }
    
</script>

<form action="index2.php" method="post" name="adminForm">
<div id="right">
	<div id="rightpad">
	
<!-- Header START -->	
		<div id="step">
			<div class="t">
        <div class="t">
          <div class="t"></div>
        </div>
      </div>
      <div class="m" align="left">
				<div class="far-right">
							<div class="button1-left"><div class="help"><a href="http://www.joomleague.de/handbuch.html" alt="<?php echo _JL_ADMIN_MANUAL;?>" title="<?php echo _JL_ADMIN_MANUAL;?>" target="blank"><?php echo _JL_ADMIN_MANUAL;?></a></div></div>
							<div class="button1-left"><div class="forum"><a href="http://www.joomleague.de/forum/" alt="<?php echo _JL_ADMIN_FORUM;?>" title="<?php echo _JL_ADMIN_FORUM;?>" target="blank"><?php echo _JL_ADMIN_FORUM;?></a></div></div>
							<div class="button1-left"><div class="about"><a href="http://www.joomleague.de" alt="<?php echo _JL_ADMIN_INFO;?>" title="<?php echo _JL_ADMIN_INFO;?>" target="blank"><?php echo _JL_ADMIN_INFO;?></a></div></div>
				</div>
				<div class="button1-left"><div class="blank"><a href="index2.php?option=com_joomleague"></a></div></div><span class="step"><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_MATCHES;?></span>
			</div>
      <div class="b">
        <div class="b">
          <div class="b"></div>
        </div>
      </div>
    </div>
<!-- Header END -->    

    <div id="installer">
    
<!-- Title 1 START -->     
			<div class="t">
        <div class="t">
          <div class="t"></div>
        </div>
      </div>
      <div class="m" align="left">
      	<h2><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_TITLE;?></h2>		
<!-- Title 1 END -->            		 
  
<!-- Content 1 START -->
<?php
list($datum, $uhrzeit)=split(" ", $row->match_date); ?>
				<div class="install-text">
	<table cellpadding="4" cellspacing="1" border="0" width="100%" class="adminform">
	<tr>
			<td align="right"><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_NR;?></td>
			<td>
				<input type="text" class="inputbox" name="match_number" value="<?php echo $row->match_number;?>" size="3" /><br />
	</tr>
	<tr>
			<td align="right"><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_DATE;?></td>
			<td>
				<input type="text" class="inputbox" name="match_date" id="match_date" size="10" value="<?php echo $datum; ?>" />
	      <input type="reset" class="inputbox" class="button" value="..." onclick="return showCalendar('match_date', 'y-mm-dd');" /><br />
				<input type="text" class="inputbox" name="match_time" size="8" value="<?php echo $uhrzeit; ?>" />
			</td>
	</tr>
  <tr>
			<td align="right"><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_HOME;?></td>
			<td><b><?php echo $team1->name; ?></b></td>
		</tr>
		<tr>
			<td align="right" valign="top"><?php echo "Startaufstellung";?></td>
			<td><?php
echo mosHTML::selectList( $homesquadoptions, 'homeroster[]', 'id="homesqad" style="font-size:9px" class="inputbox" multiple="true"','value', 'text', $temphome );?>
</td>
		</tr>
    <tr>
			<td align="right"><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_AWAY;?></td>
			<td><b><?php echo $team2->name; ?></b></td>
		</tr>
		<tr>
			<td align="right" valign="top"><?php echo _JL_STARTING_ROSTERS;?></td>
			<td><?php
echo mosHTML::selectList( $guestsquadoptions, 'awayroster[]', 'id="awaysqad" style="font-size:9px" class="inputbox" multiple="true"','value', 'text', $tempaway );?>
</td>
		</tr>
    <tr>
			<td align="right"><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_GOALS_HOME;?></td>
			<td><input type="text" class="inputbox" name="matchpart1_result" size="3" value="<?php echo $row->matchpart1_result; ?>" /></td>
		</tr>
    <tr>
      <td align="right"><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_GOALS_AWAY;?></td>
      <td><input type="text" class="inputbox" name="matchpart2_result" size="3" value="<?php echo $row->matchpart2_result; ?>" /></td>
    </tr>
    <?php 
      if ($project->use_legs == 1) { ?>
        <tr>
			<td align="right"><?php echo "Legs Home";?></td>
			<td><input type="text" class="inputbox" name="matchpart1_legs" size="3" value="<?php echo $row->matchpart1_legs; ?>" /></td>
		</tr>
    <tr>
      <td align="right"><?php echo "Legs Away";?></td>
      <td><input type="text" class="inputbox" name="matchpart2_legs" size="3" value="<?php echo $row->matchpart2_legs; ?>" /></td>
    </tr>
      <?php } ?>
    <?php 
      if ($project->game_parts > 1) { ?>
    <tr>
      <td align="right"><?php echo _JL_ADMIN_EDIT_MATRIX_ROUNDS_PART_RESULT;?></td>
      <td>
        <?php
        $partresults1=explode(";", $row->matchpart1_result_split);
        $partresults2=explode(";", $row->matchpart2_result_split);
        for ($x=0;$x<($project->game_parts-1);$x++)
        { 
        	echo ($x+1).".";
        	?>
          <input type="text" name="matchpart1_result_split[]" value="<?php echo $partresults1[$x];?>" size="3" tabindex="1" class="inputbox" />
          :
          <input type="text" name="matchpart2_result_split[]" value="<?php echo $partresults2[$x];?>" size="3" tabindex="1" class="inputbox" />
        <br />
      <? } ?>
			</td>
    </tr>
      <?php } ?>
    <tr>
      <td align="right"><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_RESULT_NOTICE;?></td>
      <td><input type="text" class="inputbox" name="match_result_detail" size="30" value="<?php echo $row->match_result_detail; ?>" /></td>
    </tr>
    <tr>
<!-- Query if result exists, if not disable radio button for alt decision-->    
<script language="javascript" type="text/javascript">
    function FormSwitch(action) {
		document.adminForm.matchpart1_result_decision.disabled=action;
		document.adminForm.matchpart2_result_decision.disabled=action;
		document.adminForm.decision_info.disabled=action;
    }
</script>
    <tr><td align='right'><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_RESULT_DECISION; ?></td>
	    <td><input type="radio" name="alt_decision" id="altdecision0" value="0" <?php if ($row->alt_decision==0) echo 'checked="checked"' ?>  onclick="javascript:FormSwitch(true)" >
			<label for="alt_decision0"><?php echo _CMN_NO ?></label>
			<input type="radio" name="alt_decision" id="altdecision1" value="1" <?php if ($row->alt_decision==1) echo 'checked="checked"' ?> onclick="javascript:FormSwitch(false)" />
			<label for="alt_decision1"><?php echo _CMN_YES ?></label>
    	</td>
	</tr>
    <tr>
		<td align="right"><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_HOME_NEW;?></td>
		<td><input type="text" class="inputbox" name="matchpart1_result_decision" size="3" value="<?php if ($row->alt_decision == 1) if (isset($row->matchpart1_result_decision)) echo $row->matchpart1_result_decision; else echo 'X'; ?>" <?php if ($row->alt_decision == 0) echo 'DISABLED ' ?>/></td>
	</tr>
    <tr>
      <td align="right"><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_AWAY_NEW;?></td>
      <td><input type="text" class="inputbox" name="matchpart2_result_decision" size="3" value="<?php if ($row->alt_decision == 1) if (isset($row->matchpart2_result_decision))  echo $row->matchpart2_result_decision; else echo 'X'; ?>" <?php if ($row->alt_decision == 0) echo 'DISABLED ' ?>/></td>
    </tr>
    <tr>
      <td align="right"><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_NOTICE_NEW;?></td><?php if (is_null($row->matchpart1_result) or ($row->alt_decision == 0)) $disinfo='DISABLED '; ?>
      <td><input type="text" class="inputbox" name="decision_info" size="30" value="<?php if ($row->alt_decision == 1) echo $row->decision_info; ?>" <?php if ($row->alt_decision == 0) echo 'DISABLED ' ?>/></td>
    </tr>
    <tr>
      <td align="right"><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_COUNT_MATCH;?></td>
      <td><?php echo mosHTML::yesnoRadioList('count_result', '', $row->count_result );?></td>
    </tr>
    <tr>
      <td align="right"><?php echo _JL_ADMIN_PUBLISHED;?></td>
      <td><?php echo mosHTML::yesnoRadioList('published', '', $row->published );?></td>
    </tr>
   </table>
				</div>
<!-- Content 1 END -->

<!-- Info 1 START -->					
				<div class="install-body">
    			<div class="t">
            <div class="t">
              <div class="t"></div>
            </div>
          </div>
          <div class="m">
						<fieldset>
							<table class="content">
							<tr>
								<td><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_HINT1;?>
								</td>
							</tr>
							</table>
						</fieldset>

					</div>
          <div class="b">
            <div class="b">
              <div class="b"></div>
            </div>
          </div>
					<div class="clr"></div>
				</div>
<!-- Info 1 END -->

<!-- Title 1 START --> 
      <div class="newsection"></div>
				<h2><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_TITLE2;?></h2>
<!-- Title 1 END --> 				

<!-- Info 2 START --> 			
		<div id="step">
			<div class="t">
        <div class="t">
          <div class="t"></div>
        </div>
      </div>
      <div class="m" align="left">
<table class="content" cellpadding="4">
 <tr>
  <td><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_HINT2;?>
  </td>
 </tr>
</table>
			</div>
      <div class="b">
        <div class="b">
          <div class="b"></div>
        </div>
      </div>
    </div>
<!-- Info 2 END -->

<!-- Content 2 START -->		
				<div class="install-text2">
	<table cellpadding="4" cellspacing="1" border="0" width="100%" class="adminform">
    <tr>
			<td align="right"><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_REFEREE;?></td>
			<td></td>
      <td align="left"><?php echo $refereelist;?></td>
		</tr>
    <tr>
			<td align="right"><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_CROWD;?></td>
			<td></td>
		  <td align="left"><input type="text" name="crowd" size="6" value="<?php echo $row->crowd; ?>"></td>
    </tr>
    <tr>
      <td align="right"><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_SHOW_MATCHREPORT;?></td>
      <td></td>
      <td align="left"><?php echo mosHTML::yesnoRadioList('show_report', '', $row->show_report );?></td>
    </tr>
    <tr>
      <td align="right"><?php echo _JL_ADMIN_EDIT_FORM_MATCHES_MATCHREPORT;?></td>
      <td></td>
      <td align="left">
<?php
			// parameters : areaname, content, hidden field, width, height, rows, cols
			editorArea( 'editor1',  $row->summary , 'summary', '600', '300', '50', '5' ) ; 
?>
      </td>
    </tr>
		</table>
				</div>
<!-- Content 2 END -->	

        <div class="clr"></div>
      </div>
      <div class="b">
        <div class="b">
          <div class="b"></div>
        </div>
      </div>
		</div>
	</div>
</div>
<div class="clr"></div>
<input type="hidden" name="match_id" value="<?php echo $row->match_id; ?>" />
<input type="hidden" name="option" value="<?php echo $option; ?>" />
<input type="hidden" name="act" value="<?php echo $act;?>" />
<input type="hidden" name="task" value="" />
</form>
